tools/xenstored: control: Store the save filename in lu_dump_state
authorJulien Grall <jgrall@amazon.com>
Thu, 25 Feb 2021 16:33:23 +0000 (16:33 +0000)
committerJulien Grall <jgrall@amazon.com>
Fri, 26 Feb 2021 09:46:12 +0000 (09:46 +0000)
commit11d9933f6bf0cdb69cdd82c5ad2213fcbe73502f
treed7ca525a4a06a8cda2250377f428a60802fd4297
parent702b44be43b431695dd9ab49ca4a89ea50e31711
tools/xenstored: control: Store the save filename in lu_dump_state

The function lu_close_dump_state() will use talloc_asprintf() without
checking whether the allocation succeeded. In the unlikely case we are
out of memory, we would dereference a NULL pointer.

As we already computed the filename in lu_get_dump_state(), we can store
the name in the lu_dump_state. This is avoiding to deal with memory file
in the close path and also reduce the risk to use the different
filename.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: c0dc6a3e7c41 ("tools/xenstore: read internal state when doing live upgrade")
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
tools/xenstore/xenstored_control.c